package com.newenergy.wisehome.gateway.adapter;


import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.newenergy.wisehome.R;
import com.newenergy.wisehome.data.bean.UserInfoItem;

import java.util.List;

public class UserInfoAdapter extends RecyclerArrayAdapter<UserInfoItem> {

    public void refreshData(List<UserInfoItem> data) {
        clear();
        addAll(data);
        notifyDataSetChanged();
    }

    public UserInfoAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int
            viewType) {
        return new ViewHolder(parent);
    }

    private class ViewHolder extends BaseViewHolder<UserInfoItem> {

        private TextView tvTitle;
        private TextView tvSubTitle;

        public ViewHolder(ViewGroup parent) {
            super(parent, R.layout.item_user_info);
            tvTitle = $(R.id.tv_title);
            tvSubTitle = $(R.id.tv_subTitle);
        }
        @Override
        public void setData(UserInfoItem data) {
            super.setData(data);
            tvTitle.setText(data.getTitle());
            tvSubTitle.setText(data.getSubTitle());
        }
    }
}

//public class UserInfoAdapter extends BaseQuickAdapter<UserInfoItem, UserInfoAdapter.ViewHolder> {
//    public UserInfoAdapter(int layoutResId, @Nullable List<UserInfoItem> data) {
//        super(layoutResId, data);
//    }
//
//    public UserInfoAdapter(@Nullable List<UserInfoItem> data) {
//        super(data);
//    }
//
//    public UserInfoAdapter(int layoutResId) {
//        super(layoutResId);
//    }
//
//    @Override
//    protected void convert(ViewHolder helper, UserInfoItem item) {
//        helper.setText(R.id.tv_title, item.getTitle());
//        helper.setText(R.id.tv_subTitle, item.getSubTitle());
//    }
//
//    class ViewHolder extends BaseViewHolder {
//        public ViewHolder(View view) {
//            super(view);
//        }
//    }
//}